// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import './styles/reset.css'
import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui'
import Resource from 'vue-resource'
import $cookie from './js/cookie.js'

Vue.config.productionTip = false;
Vue.use(ElementUI);
Vue.use(Resource);
Vue.http.options.headers = { //为ajax统一设置headers
	'Content-Type': 'x-www-form-urlencoded'
}
$cookie.set('timeout','false');
Vue.http.interceptors.push((request, next) => {
	let timeout = $cookie.get('timeout') || '';
    if(timeout == 'true'){return;}
    next((response) => {
    	JSON.parse(response.bodyText).statusCode == 302 ? $cookie.set('timeout','true'):$cookie.remove('timeout');
        return response;
    });
});
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})
